/**
 * Copyright ©2012-2018 HopeHaiyang Corporation, All Rights Reserved
 * http://www.wuhanhope.com
 */
package hope.platform.data.web;

import hope.platform.data.domain.Role;
import hope.platform.data.server.data.header.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * class info
 *
 * @author hujia
 *         Create at 2018/7/17 10:19
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @RequestMapping(value = "/roleName/{roleName}", method = RequestMethod.GET)
    public Role getByRoleName(@PathVariable String roleName) throws Exception {
        return roleService.getByRoleName(roleName);
    }

    @RequestMapping(method = RequestMethod.POST)
    public Role addRole(@RequestBody Role role) {
        return roleService.addRole(role);
    }

    @RequestMapping(method = RequestMethod.PUT)
    public Role updateRole(@RequestBody Role role) {
        return roleService.updateRole(role);
    }
}
